package com.korubo.web.contrller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.korubo.kit.R;
import com.korubo.web.model.Dict;
import com.korubo.web.service.DictService;
import com.korubo.web.service.impl.DictServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (tb_dict)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/dict")
public class DictController {
    /**
     * 服务对象
     */
    @Resource
    private DictService dictService;

    //根据类型查询
    @PostMapping("list")
    public R list(Dict dict) {
        QueryWrapper<Dict> queryWrapper = new QueryWrapper<>();
        if (StrUtil.isNotBlank(dict.getType())) {
            queryWrapper.eq("type", dict.getType());
        }
        List<Dict> list = dictService.list(queryWrapper);
        return R.ok(list);
    }


}
